# coding = utf8
from application.utils.MySQLUtils import MySQLUtils
import pandas as pd
from application.logging import logger


def get_all_area_code():
    """
    查询地区编码
    source_code=2 顶秀金石
    source_code=1 TODO 天气API
    source_code=0 TODO 和风天气网
    :return:
    """
    # 查询语句：排重
    sql = "SELECT DISTINCT area_code FROM  public_basic_forecast_weather WHERE source_code=2"
    # 获取连接
    con = MySQLUtils.get_mysql_connection()
    # 查询数据
    df = pd.read_sql_query(sql, con=con)
    # 打印数据
    logger.info(df)
    # 筛选数据
    df = df['area_code']
    logger.info(df)
    # 转换数据
    ls_area_code = list(df)
    logger.info(ls_area_code)
    # 返回数据
    return ls_area_code
    pass


if __name__ == '__main__':
    """
    main 测试方法
    """
    get_all_area_code()  # 110106000000
    pass
